import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AccountVO, AccountForm, AccountQuery } from '@/api/retail/account/types';

/**
 * 查询资金账号列表
 * @param query
 * @returns {*}
 */

export const listAccount = (query?: AccountQuery): AxiosPromise<AccountVO[]> => {
  return request({
    url: '/retail/account/list',
    method: 'get',
    params: query
  });
};

/**
 * 账户资金统计
 */
export const statAccount = () => {
  return request({
    url: '/retail/account/stat',
    method: 'get'
  });
}

/**
 * 查询资金账号详细
 * @param id
 */
export const getAccount = (id: string | number): AxiosPromise<AccountVO> => {
  return request({
    url: '/retail/account/' + id,
    method: 'get'
  });
};

export const adjugementAmount = (id: string | number, bizType: string, amount: number, validCode: string) => {
  const params = {
    amount: amount,
    validCode: validCode
  };
  return request({
    url: '/retail/account/change/' + bizType + '/' + id,
    method: 'post',
    data: params
  });
};
